/**
 * 
 */
package arisufascion.com.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * @author Kelvin
 *
 */
public class MySQLiteHelper extends SQLiteOpenHelper{
	 private static final int DATABASE_VERSION = 3;
	 
	public MySQLiteHelper(Context context) {
	    super(context, TblProduct.TABLE_NAME, null, DATABASE_VERSION);
	  }

	  @Override
	  public void onCreate(SQLiteDatabase database) {
	    database.execSQL(TblProduct.TABLE_CREATE);
	    database.execSQL(TblProductImage.TABLE_CREATE);
	    database.execSQL(TblProfile.TABLE_CREATE);
	    database.execSQL(TblColor.TABLE_CREATE);
	  }

	  @Override
	  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	    Log.w(MySQLiteHelper.class.getName(),
	        "Upgrading database from version " + oldVersion + " to "
	            + newVersion + ", which will destroy all old data");
	    db.execSQL("DROP TABLE IF EXISTS " + TblProduct.TABLE_NAME);
	    db.execSQL("DROP TABLE IF EXISTS " + TblProductImage.TABLE_NAME);
	    db.execSQL("DROP TABLE IF EXISTS " + TblProfile.TABLE_NAME);
	    db.execSQL("DROP TABLE IF EXISTS " + TblColor.TABLE_NAME);
	    onCreate(db);
	  }
	  
}
